package com.mk.dynamic.redis;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(prefix = DynamicRedisProperties.PREFIX, value = "enabled", matchIfMissing = false)
public class DynamicRedisConfig {

    @Bean
    public DynamicRedisProperties dynamicRedisProperties() {
        return new DynamicRedisProperties();
    }

    @Bean
    @ConditionalOnMissingBean
    public DynamicRedisProvider dynamicRedisProvider() {
        return new YamlDynamicRedisProvider(dynamicRedisProperties());
    }
}
